<?php
namespace app\validate;
use share\validate\SceneValidate;

class OssOrderValidate extends SceneValidate{

    /**
     * 通用规则
     */
    protected $rule = [
        'id' => 'require|integer',
        'name' => 'require|length:2,16',
        'sn' => 'require|alphaNum|length:2,64',
    ];    

    /**
     * 自定义场景的规则
     */
    protected $sceneRules = [
        'set' =>[
            'id' => 'require|integer',
            'level' => 'integer',
            'account' => 'length:2,16',
            'password' => 'length:6,20',
            'vendor' => 'length:2,20',
        ],
        'list' => [
            'order_no' => 'length:2,30',
            'open_app_id' => 'integer',
            'prodoct_id' => 'integer',
            'aliyun_cloud_storage_id' => 'integer',
            'state' => 'integer',
            'out_trade_no' => 'length:2,80',
            'money' => 'integer',
            'user_id' => 'length:2,64',
            'iot_id' => 'length:2,64',
            'sn'  => 'alphaNum|length:2,64',
        ],
        'open_list' => [
            'state' => 'integer|between:1,10',
            'userId' => 'alphaNum|length:2,64',
            'iotId' => 'alphaNum|length:2,64',
        ],
        'open_detail' => [
            'id' => 'integer|>:0',
            'orderNo' => 'alphaNum|length:10,32',
            'outTradeNo' => 'alphaNum|length:5,80',
        ],
        'open_create' => [
            'userId' => 'require|alphaNum|length:2,64',
            'sn' => 'require|alphaNum|length:2,64',
            'sku' => 'require|alphaNum|length:2,64',
            'outTradeNo' => 'require|alphaNum|length:5,80',
            'num' => 'require|integer|between:1,100',
            'extend' => 'array',
        ],
        'open_create_extend' => [
            'enableDefaultPlan' => 'integer|between:0,1',
            'preRecordDuration' => 'integer|between:0,5',
            'recordDuration' => 'integer|between:0,30',
            'eventRecordProLong' => 'integer|between:0,1',
            'maxRecordFileDuration' => 'integer|between:600,3600',
        ],
    ];

    protected $scene = [
        'list' => [
            'order_no','open_app_id','out_trade_no','prodoct_id','aliyun_cloud_storage_id',
            'state','money','user_id','sn',
        ],
        'set' => ['id','level','account','password','vendor'],
        'del'  => ['id'],
        'open_list' => [
            'state','user_id','sn',
        ],
        'open_detail' => [
            'id','orderNo','out_trade_no',
        ],
        'open_create' => [
            'user_id','sn','sku','out_trade_no','num','extend'
        ],
        'open_create_extend' => [
            "enableDefaultPlan",
            "preRecordDuration",
            "recordDuration",
            "eventRecordProLong",
            'maxRecordFileDuration',
        ],
        'buy' => [
            'out_trade_no'
        ],
        'createAndBuy' => [
            'user_id','sn','sku','out_trade_no','num','extend'
        ],
        'payedProduct' => [
            'sn'
        ],
        'isCanBuy' => [
            'sn','user_id',
        ],
    ];
}
